import utime
from neopixel import NeoPixel
from machine import Pin
from 驱动.ws2812Screen import WS2812Screen
# from ImgData import *
import time
import random
from setting import *

SCREEN_WIDTH = 32  # 屏幕宽
SCREEN_HEIGHT = 8  # 屏幕高

num_leds = SCREEN_WIDTH * SCREEN_HEIGHT  # 像素数量(led灯珠数量)

np = NeoPixel(Pin(LED_PIN), num_leds + 64)  # 创建像素序列对象

screen = WS2812Screen(np, SCREEN_WIDTH, SCREEN_HEIGHT)  # 创建屏幕对象

mic = Pin(MIC_PIN)


while True:
    screen.fill_screen()
#     if mic.value() == 0:
#         print("有声音")
    for x in range(SCREEN_WIDTH):
        r = random.randint(0, 255)
        g = random.randint(0, 255)
        b = random.randint(0, 255)
        color = (r, g, b)
        for y in range(random.randint(1, 7)):

            screen.draw_pixel(x, 7-y, color)
    time.sleep_ms(100)
    screen.show()
    
